from enum import Enum
from typing import Optional

from pydantic import BaseModel, Field


class Provider(str, Enum):
    aliyun = "aliyun"
    tencent = "tencent"
    volcano = "volcano"


class CredentialBase(BaseModel):
    provider: Provider = Field(..., description="云厂商标识")
    account_name: str = Field(..., description="账号昵称")
    access_key: str = Field(..., description="Access Key ID")
    secret_key: str = Field(..., description="Access Key Secret")
    description: Optional[str] = Field(default=None, description="备注说明")


class CredentialCreate(CredentialBase):
    pass


class CredentialUpdate(BaseModel):
    id: str
    account_name: Optional[str] = None
    access_key: Optional[str] = None
    secret_key: Optional[str] = None
    description: Optional[str] = None


class CredentialDeleteRequest(BaseModel):
    id: str


class CredentialDescribeRequest(BaseModel):
    id: str


class CredentialListRequest(BaseModel):
    provider: Optional[Provider] = None


class Credential(BaseModel):
    id: str
    provider: Provider
    account_name: str
    access_key: str
    description: Optional[str] = None
    secret_preview: str
